using Core.Contracts.Interfaces;

namespace Core.Features
{
    using System;
    using Base;
    using Contracts.Enums;
    using Resources;
    using System.Linq;

    
    public sealed class SensorAmpLockingTime<T> : FeatureBase<object>
    {
        public SensorAmpLockingTime(){}

        public SensorAmpLockingTime(T value) 
            : base(value){ }
        /// <summary>
        /// Obtains the feature name
        /// </summary>
        public override string Name
        {
            get { return "Locking time"; }
        }
        /// <summary>
        /// Obtains the feature group
        /// </summary>
        public override FeatureGroupsEnum FeatureGroup{ get { return FeatureGroupsEnum.Specific; } }
        /// <summary>
        /// Obtains the feature type
        /// </summary>
        public override FeaturesEnum FeatureType { get { return FeaturesEnum.SensorAmpLockingTime; } }
        /// <summary>
        /// Obtains or defines the feature unit
        /// </summary>
        public override string Unit { get { return Traduction.label_unit_percent ; } }

        /// <summary>
        /// Determines if the feature value is rounded
        /// </summary>
        public override bool IsRounded
        {
            get { return false; }
        }
        public override void SetModifiedValue(IAgent agent, IRobot robot)
        {
            if (robot == null || agent == null) return;

            // Bonuses from extensions
            double extensionBonus = agent.Extensions.SumModifiersValues(FeatureTypesEnum.Module, this.FeatureType);

            // Bonuses from robot
            double robotBonus = robot.Modifiers.SumModifiersValues(agent.Extensions, FeatureTypesEnum.Module, this.FeatureType);

            double temp = (90 - (double)Value) / 100 * (extensionBonus + robotBonus) + (double)Value;


            ModifiedValue = IsRounded
                ? Math.Round(temp, 0, MidpointRounding.AwayFromZero)
                : Math.Round(temp, 0);
        }
        
    }
}